﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sheeps
{
    public class RandomSheepGenerator : SheepGenerator
    {
        public double BorderWeight { get; set; }

        /// <summary>
        /// Sheep are randomly placed on pasture
        /// </summary>
        /// <param name="gameState"></param>
        /// <param name="count"></param>
        public override void GenerateSheep(GameState gameState, int count)
        {
            Random rand = new Random();

            double maxX = (1-BorderWeight) * gameState.Width * 10;
            double xOffs = gameState.Width*BorderWeight/2;
            double maxY = (1 - BorderWeight) * gameState.Height * 10;
            double yOffs = gameState.Height*BorderWeight/2;

            for (int i = 0; i < count; i++)
            {
                Sheep sheep = new Sheep()
                {
                    Position = new Vector3(
                        (double)rand.Next((int)maxX) / 10.0 + xOffs,
                        (double)rand.Next((int)maxY) / 10.0 + yOffs,
                        0.0)
                };
                gameState.SheepList.Add(sheep);
            }
        }

        public override void GenerateDog(GameState gameState)
        {
            gameState.Dog = new Dog();
            gameState.Dog.Position = new Vector3(100, 100, 0);
        }

        public RandomSheepGenerator()
        {
            this.BorderWeight = 0.1;
        }
    }
}
